package com.netflexitysolutions.amazonws.ec2.internal.operations;

import com.amazonaws.ec2.doc._2009_04_04.CreateKeyPairResponseType;
import com.amazonaws.ec2.doc._2009_04_04.CreateKeyPairType;
import com.netflexitysolutions.amazonws.ec2.EC2;
import com.netflexitysolutions.amazonws.ec2.KeyPair;

public class CreateKeyPairOperation extends SingleObjectOperationExecutor<CreateKeyPairType, KeyPair> {

	public CreateKeyPairOperation(EC2 ec2, String keyName) {
		super(ec2, keyName);
	}

	@Override
	protected KeyPair call(CreateKeyPairType request) {
		request.setKeyName(objectId);
		CreateKeyPairResponseType response = getEC2().getService().createKeyPair(request);
		return new KeyPair(response.getKeyName(), response.getKeyFingerprint(), response.getKeyMaterial());
	}

}
